package cn.enilu.flash.enums.body;

import cn.enilu.flash.enums.OptionObject;

import java.util.HashMap;
import java.util.Map;

/**
 * @Description
 * @Author Spark
 * @Date Created in (2019/10/30 15:54)
 * @Version v1.0
 * @Modify
 **/
public enum PayState implements OptionObject {
    PAID(1, "已支付"),
    UNPAID(0, "未支付")
    ;

    private int code;
    private String text;


    PayState(int code, String text){
        this.code = code;
        this.text = text;
    }

    public static Map<Integer, String> toMap = new HashMap<Integer, String>();

    static {
        PayState[] types = PayState.values();
        for (PayState type : types) {
            toMap.put(type.getCode(), type.getText());
        }
    }

    public static String valueOfCode(int code) {
        PayState[] bts = PayState.values();
        for (PayState bt : bts) {
            if(bt.getCode() == code){
                return bt.getText();
            }
        }
        return "--";
    }

    @Override
    public int getCode() {
        return this.code;
    }

    @Override
    public String getText() {
        return this.text;
    }

    @Override
    public boolean compare(int code){
        if(this.getCode() == code){
            return true;
        }
        return false;
    }
}
